package com.simple.crawler.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class  CrawlerLogger {

    private String id = StringUtils.getId(16);

    private Logger logger;

    public static CrawlerLogger getLogger(Class<?> clazz) {
        return new CrawlerLogger(clazz);
    }

    private CrawlerLogger(Class<?> clazz) {
        this.logger = LoggerFactory.getLogger(clazz);
    }

    public void info(String s, Object... args) {
        this.logger.info("[id=" + id +"]:" + s, args);
    }

    public void warn(String s, Object... args) {
        this.logger.warn("[id=" + id +"]:" + s, args);
    }

    public void debug(String s, Object... args) {
        if (!logger.isDebugEnabled()) {
            return;
        }
        this.logger.debug("[id=" + id +"]:" + s, args);
    }

    public void error(String s, Object... args) {
        this.logger.error("[id=" + id +"]:" + s, args);
    }

}
